#include	"../utils/logger.h"
#include	"api_def.h"

static int Api_LogVerbose(lua_State * pL) {
	const char * pMsg = lua_tostring(pL, 1);
	LOG_DEBUG(pMsg);
	return 0;
}

static int Api_LogInfo(lua_State * pL) {
	const char * pMsg = lua_tostring(pL, 1);
	LOG_INFO(pMsg);
	return 0;
}

static int Api_LogWarning(lua_State * pL) {
	const char * pMsg = lua_tostring(pL, 1);
	LOG_WARN(pMsg);
	return 0;
}

static int Api_LogError(lua_State * pL) {
	const char * pMsg = lua_tostring(pL, 1);
	LOG_ERR(pMsg);
	return 0;
}

void RegisterApi_Logger(lua_State * pL) {
	lua_newtable(pL);
	lua_setglobal(pL, "log");

	lua_getglobal(pL, "log");
	REGMETAAPI(pL, Api_LogVerbose, "verbose");
	REGMETAAPI(pL, Api_LogInfo, "info");
	REGMETAAPI(pL, Api_LogWarning, "warning");
	REGMETAAPI(pL, Api_LogError, "error");
	lua_pop(pL, 1);
}
